// pages/myorder/myorderlist/myorderlist.js
import {
  getaftersalelist,
  searchAfterSale
} from '../../../utils/networkRequest.js'
import {
  errorMsg
} from '../../../utils/tool.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 0,
    datalist: [],
    keyword: "",
  },
  onLoad: function() {
    let self = this;
    
  },
 
  goAFCreate: function() {
    wx.navigateTo({
      url: '../aftersalecreate/aftersalecreate',
    })
  },
  //查看售后详情
  goAFDetail: function(e) {
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../aftersaledetailview/aftersaledetailview?id=' + id,
    })
  },
  getkeyword: function(e) {
    this.setData({
      keyword: e.detail.value,

    })
  },
  //搜索
  onsearch: function() {
    let {
      keyword
    } = this.data;
    let self = this;
    searchAfterSale(keyword, (r) => {
      if (r.code == 0) {
        self.setData({
          datalist: r.data
        })
      }
    })
  },
  //跳转到物流查询
  expressSearch: function (e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../viewexpress/viewexpress?id=' + id,
    })
  },
  //扫一扫获取二维码
  onScanCodeSearch: function() {
    wx.scanCode({
      success: (res) => {

        searchAfterSale(res.result, (r) => {
          if (r.code == 0) {

          }
        })
      },
      fail: (res) => {
        errorMsg("识别失败")
      }
    })
  },
  preImg: function (e) {
    let src = e.currentTarget.dataset.src
    wx.previewImage({
      current: src, // 当前显示图片的http链接
      urls: [src] // 需要预览的图片http链接列表
    })
  }
})